import {Vertex2} from "./Direction2D";
import {Length2D} from "./Length2D";

type TriangleInfo = [Vertex2, Vertex2, Vertex2];

let AreaOfTriangle = (triangle: TriangleInfo) => {
    let [v0, v1, v2] = triangle;
    let a = Length2D(v0, v1), b = Length2D(v1, v2), c = Length2D(v2, v0);
    let s = (a + b + c) / 2;
    return (s * (s - a) * (s - b) * (s - c)) ** (1/2);
};

export {AreaOfTriangle, TriangleInfo};